package cn.com.homeyoda.aimate.aihealth.ui.record.physical_exam;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.ExaminationReportBean;

public class PhysicalExamRecordAdapter extends BaseQuickAdapter<ExaminationReportBean.RowsBean, BaseViewHolder> {

    public PhysicalExamRecordAdapter(int layoutResId) {
        super(layoutResId);
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, ExaminationReportBean.RowsBean item) {
        int color = ContextCompat.getColor(mContext, helper.getLayoutPosition() % 2 == 0 ? R.color.clr_0065FF_6 : R.color.clr_0065FF_2);

        helper.setBackgroundColor(R.id.ll_physical_exam_time, color);
        // helper.setBackgroundColor(R.id.ll_physical_exam_device, color);
        helper.setBackgroundColor(R.id.ll_health_score, color);
        // helper.setBackgroundColor(R.id.ll_sync_delete_record, color);
        helper.setBackgroundColor(R.id.tv_delete_record, color);

        helper.setText(R.id.tv_physical_exam_time, item.getAddTime());
        // helper.setText(R.id.tv_physical_exam_device, item.getDevice());
        helper.setText(R.id.tv_health_score, String.valueOf(item.getScore()));

        int textColor;
        int score = item.getScore();
        if (score >= 90) {
            textColor = R.color.clr_0AA5A8;
        } else if (score >= 70) {
            textColor = R.color.clr_F77234;
        } else {
            textColor = R.color.clr_FF3333;
        }
        helper.setTextColor(R.id.tv_health_score, ContextCompat.getColor(mContext, textColor));
        // helper.setGone(R.id.tv_physical_exam_device_synced, !item.isSynced());
        helper.addOnClickListener(R.id.tv_view_record);
        // helper.addOnClickListener(R.id.tv_sync_record);
        helper.addOnClickListener(R.id.tv_delete_record);
    }

    @Override
    public void setNewData(@Nullable List<ExaminationReportBean.RowsBean> data) {
        super.setNewData(data);
    }
}
